package tcp_net.mail.pop3.commands;

import tcp_net.mail.MailBoxFileManager;
import tcp_net.mail.pop3.commands.debug.DebugInfo;

import java.util.List;
import java.util.ArrayList;

/**
	This class provides a defined command to be executed
	@author J. Okuno
*/
public class DELE extends POP3Command 
{
	/**
		A message number
	*/
	private int msg;
	
	/**
		Init the class
		@param m a message number
		@param man a mailbox file manager
	*/
	public DELE(int m, MailBoxFileManager man) 
	{ 
		super(man);
		msg = m; 
	}
	
	/**
		This method executes a defined command
		@return a list of reply messages in a string format
	*/
	public List<String> execute() 
	{
		//Mark delete
		if(manager.markMessageDelete(msg))
		{
			String rep_msg = "message" + msg + " deleted";
		
			reply = new POP3ReplyMessage(true, rep_msg);
			reply_msgs.add(reply.execute().get(0));
		
			
		}
		
		//Error
		else
		{
			String rep_msg = "message" + msg + " not deleted";
			
			reply = new POP3ReplyMessage(false, rep_msg);
			reply_msgs.add(reply.execute().get(0));
		}
		
		return reply_msgs;
	}
}